{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pandas怎样实现groupby聚合后字符串列的合并"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 需求：  \n",
    "计算每个月的最高温度、最低温度、出现的风向列表、出现的空气质量列表\n",
    "\n",
    "#### 数据输入\n",
    "<img src=\"./other_files/grouby_join_input.png\" style=\"margin-left:0px; width:60%\"/>\n",
    "\n",
    "#### 数据输出\n",
    "<img src=\"./other_files/grouby_join_output.png\" style=\"margin-left:0px; width:60%\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 读取数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ymd</th>\n",
       "      <th>bWendu</th>\n",
       "      <th>yWendu</th>\n",
       "      <th>tianqi</th>\n",
       "      <th>fengxiang</th>\n",
       "      <th>fengli</th>\n",
       "      <th>aqi</th>\n",
       "      <th>aqiInfo</th>\n",
       "      <th>aqiLevel</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>3℃</td>\n",
       "      <td>-6℃</td>\n",
       "      <td>晴~多云</td>\n",
       "      <td>东北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>59</td>\n",
       "      <td>良</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>2℃</td>\n",
       "      <td>-5℃</td>\n",
       "      <td>阴~多云</td>\n",
       "      <td>东北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>49</td>\n",
       "      <td>优</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>2℃</td>\n",
       "      <td>-5℃</td>\n",
       "      <td>多云</td>\n",
       "      <td>北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>28</td>\n",
       "      <td>优</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          ymd bWendu yWendu tianqi fengxiang fengli  aqi aqiInfo  aqiLevel\n",
       "0  2018-01-01     3℃    -6℃   晴~多云       东北风   1-2级   59       良         2\n",
       "1  2018-01-02     2℃    -5℃   阴~多云       东北风   1-2级   49       优         1\n",
       "2  2018-01-03     2℃    -5℃     多云        北风   1-2级   28       优         1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "fpath = \"./datas/beijing_tianqi/beijing_tianqi_2018.csv\"\n",
    "df = pd.read_csv(fpath)\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 知识：使用df.info()可以查看每列的类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 365 entries, 0 to 364\n",
      "Data columns (total 9 columns):\n",
      " #   Column     Non-Null Count  Dtype \n",
      "---  ------     --------------  ----- \n",
      " 0   ymd        365 non-null    object\n",
      " 1   bWendu     365 non-null    object\n",
      " 2   yWendu     365 non-null    object\n",
      " 3   tianqi     365 non-null    object\n",
      " 4   fengxiang  365 non-null    object\n",
      " 5   fengli     365 non-null    object\n",
      " 6   aqi        365 non-null    int64 \n",
      " 7   aqiInfo    365 non-null    object\n",
      " 8   aqiLevel   365 non-null    int64 \n",
      "dtypes: int64(2), object(7)\n",
      "memory usage: 25.8+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 知识：series怎样从str类型变成int"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>ymd</th>\n",
       "      <th>bWendu</th>\n",
       "      <th>yWendu</th>\n",
       "      <th>tianqi</th>\n",
       "      <th>fengxiang</th>\n",
       "      <th>fengli</th>\n",
       "      <th>aqi</th>\n",
       "      <th>aqiInfo</th>\n",
       "      <th>aqiLevel</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>3</td>\n",
       "      <td>-6</td>\n",
       "      <td>晴~多云</td>\n",
       "      <td>东北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>59</td>\n",
       "      <td>良</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-01-02</td>\n",
       "      <td>2</td>\n",
       "      <td>-5</td>\n",
       "      <td>阴~多云</td>\n",
       "      <td>东北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>49</td>\n",
       "      <td>优</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-01-03</td>\n",
       "      <td>2</td>\n",
       "      <td>-5</td>\n",
       "      <td>多云</td>\n",
       "      <td>北风</td>\n",
       "      <td>1-2级</td>\n",
       "      <td>28</td>\n",
       "      <td>优</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          ymd  bWendu  yWendu tianqi fengxiang fengli  aqi aqiInfo  aqiLevel\n",
       "0  2018-01-01       3      -6   晴~多云       东北风   1-2级   59       良         2\n",
       "1  2018-01-02       2      -5   阴~多云       东北风   1-2级   49       优         1\n",
       "2  2018-01-03       2      -5     多云        北风   1-2级   28       优         1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"bWendu\"] = df[\"bWendu\"].str.replace(\"℃\", \"\").astype('int32')\n",
    "df[\"yWendu\"] = df[\"yWendu\"].str.replace(\"℃\", \"\").astype('int32')\n",
    "df.head(3)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 知识：进行日期列解析，可以方便提取月份"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "df[\"ymd\"] = pd.to_datetime(df[\"ymd\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0       1\n",
       "1       1\n",
       "2       1\n",
       "3       1\n",
       "4       1\n",
       "       ..\n",
       "360    12\n",
       "361    12\n",
       "362    12\n",
       "363    12\n",
       "364    12\n",
       "Name: ymd, Length: 365, dtype: int64"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"ymd\"].dt.month"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 知识：series可以用Series.unique去重"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['东北风', '北风', '西北风', '西南风', '南风', '东南风', '东风', '西风'], dtype=object)"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"fengxiang\"].unique()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 知识：可以用\",\".join(series)实现数组合并成大字符串"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'东北风,北风,西北风,西南风,南风,东南风,东风,西风'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\",\".join(df[\"fengxiang\"].unique())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 方法1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "result = (\n",
    "    df.groupby(df[\"ymd\"].dt.month)\n",
    "      .agg(\n",
    "          # 新列名 = (原列名，函数)\n",
    "          最高温度=(\"bWendu\", \"max\"),\n",
    "          最低温度=(\"yWendu\", \"min\"),\n",
    "          风向列表=(\"fengxiang\", lambda x : \",\".join(x.unique())),\n",
    "          空气质量列表=(\"aqiInfo\", lambda x : \",\".join(x.unique()))\n",
    "      )\n",
    "      .reset_index()\n",
    "      .rename(columns={\"ymd\":\"月份\"})\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>月份</th>\n",
       "      <th>最高温度</th>\n",
       "      <th>最低温度</th>\n",
       "      <th>风向列表</th>\n",
       "      <th>空气质量列表</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>-12</td>\n",
       "      <td>东北风,北风,西北风,西南风,南风,东南风,东风</td>\n",
       "      <td>良,优,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "      <td>-10</td>\n",
       "      <td>北风,西南风,南风,西北风,西风,东北风,东风</td>\n",
       "      <td>良,优,轻度污染,中度污染,重度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>27</td>\n",
       "      <td>-4</td>\n",
       "      <td>西南风,北风,东南风,南风,东北风,东风</td>\n",
       "      <td>优,良,重度污染,轻度污染,中度污染,严重污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>30</td>\n",
       "      <td>1</td>\n",
       "      <td>南风,北风,东北风,西南风,西北风,东南风</td>\n",
       "      <td>重度污染,良,优,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>35</td>\n",
       "      <td>10</td>\n",
       "      <td>东北风,北风,西南风,南风,东南风,东风,西风,西北风</td>\n",
       "      <td>轻度污染,优,良,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>38</td>\n",
       "      <td>17</td>\n",
       "      <td>西南风,南风,北风,东风,东南风,东北风</td>\n",
       "      <td>良,轻度污染,优,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>37</td>\n",
       "      <td>22</td>\n",
       "      <td>东南风,西南风,南风,东北风,东风,西风,北风</td>\n",
       "      <td>良,轻度污染,优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>36</td>\n",
       "      <td>20</td>\n",
       "      <td>东南风,南风,东风,东北风,北风,西南风</td>\n",
       "      <td>良,轻度污染,优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>31</td>\n",
       "      <td>11</td>\n",
       "      <td>南风,北风,西南风,西北风</td>\n",
       "      <td>优,良,轻度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>1</td>\n",
       "      <td>北风,西北风,南风,西风,东北风,西南风</td>\n",
       "      <td>优,良,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>18</td>\n",
       "      <td>-4</td>\n",
       "      <td>南风,北风,西南风,东南风,西北风,东北风</td>\n",
       "      <td>良,轻度污染,重度污染,优,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "      <td>-12</td>\n",
       "      <td>东南风,东北风,西北风,西南风</td>\n",
       "      <td>中度污染,重度污染,良,优,轻度污染</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    月份  最高温度  最低温度                         风向列表                   空气质量列表\n",
       "0    1     7   -12     东北风,北风,西北风,西南风,南风,东南风,东风            良,优,轻度污染,中度污染\n",
       "1    2    12   -10      北风,西南风,南风,西北风,西风,东北风,东风       良,优,轻度污染,中度污染,重度污染\n",
       "2    3    27    -4         西南风,北风,东南风,南风,东北风,东风  优,良,重度污染,轻度污染,中度污染,严重污染\n",
       "3    4    30     1        南风,北风,东北风,西南风,西北风,东南风       重度污染,良,优,轻度污染,中度污染\n",
       "4    5    35    10  东北风,北风,西南风,南风,东南风,东风,西风,西北风            轻度污染,优,良,中度污染\n",
       "5    6    38    17         西南风,南风,北风,东风,东南风,东北风            良,轻度污染,优,中度污染\n",
       "6    7    37    22      东南风,西南风,南风,东北风,东风,西风,北风                 良,轻度污染,优\n",
       "7    8    36    20         东南风,南风,东风,东北风,北风,西南风                 良,轻度污染,优\n",
       "8    9    31    11                南风,北风,西南风,西北风                 优,良,轻度污染\n",
       "9   10    25     1         北风,西北风,南风,西风,东北风,西南风            优,良,轻度污染,中度污染\n",
       "10  11    18    -4        南风,北风,西南风,东南风,西北风,东北风       良,轻度污染,重度污染,优,中度污染\n",
       "11  12    10   -12              东南风,东北风,西北风,西南风       中度污染,重度污染,良,优,轻度污染"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 方法2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "def agg_func(x):\n",
    "    \"\"\"注意，这个x是每个分组的dataframe\"\"\"\n",
    "    return pd.Series({\n",
    "        \"最高温度\": x[\"bWendu\"].max(),\n",
    "        \"最低温度\": x[\"yWendu\"].min(),\n",
    "        \"风向列表\": \",\".join(x[\"fengxiang\"].unique()),\n",
    "        \"空气质量列表\": \",\".join(x[\"aqiInfo\"].unique())\n",
    "    })\n",
    "\n",
    "result = df \\\n",
    "        .groupby(df[\"ymd\"].dt.month) \\\n",
    "        .apply(agg_func) \\\n",
    "        .reset_index() \\\n",
    "        .rename(columns={\"ymd\":\"月份\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>月份</th>\n",
       "      <th>最高温度</th>\n",
       "      <th>最低温度</th>\n",
       "      <th>风向列表</th>\n",
       "      <th>空气质量列表</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>7</td>\n",
       "      <td>-12</td>\n",
       "      <td>东北风,北风,西北风,西南风,南风,东南风,东风</td>\n",
       "      <td>良,优,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>12</td>\n",
       "      <td>-10</td>\n",
       "      <td>北风,西南风,南风,西北风,西风,东北风,东风</td>\n",
       "      <td>良,优,轻度污染,中度污染,重度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>27</td>\n",
       "      <td>-4</td>\n",
       "      <td>西南风,北风,东南风,南风,东北风,东风</td>\n",
       "      <td>优,良,重度污染,轻度污染,中度污染,严重污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>30</td>\n",
       "      <td>1</td>\n",
       "      <td>南风,北风,东北风,西南风,西北风,东南风</td>\n",
       "      <td>重度污染,良,优,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>35</td>\n",
       "      <td>10</td>\n",
       "      <td>东北风,北风,西南风,南风,东南风,东风,西风,西北风</td>\n",
       "      <td>轻度污染,优,良,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>38</td>\n",
       "      <td>17</td>\n",
       "      <td>西南风,南风,北风,东风,东南风,东北风</td>\n",
       "      <td>良,轻度污染,优,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>37</td>\n",
       "      <td>22</td>\n",
       "      <td>东南风,西南风,南风,东北风,东风,西风,北风</td>\n",
       "      <td>良,轻度污染,优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>36</td>\n",
       "      <td>20</td>\n",
       "      <td>东南风,南风,东风,东北风,北风,西南风</td>\n",
       "      <td>良,轻度污染,优</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>31</td>\n",
       "      <td>11</td>\n",
       "      <td>南风,北风,西南风,西北风</td>\n",
       "      <td>优,良,轻度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>25</td>\n",
       "      <td>1</td>\n",
       "      <td>北风,西北风,南风,西风,东北风,西南风</td>\n",
       "      <td>优,良,轻度污染,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>18</td>\n",
       "      <td>-4</td>\n",
       "      <td>南风,北风,西南风,东南风,西北风,东北风</td>\n",
       "      <td>良,轻度污染,重度污染,优,中度污染</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>10</td>\n",
       "      <td>-12</td>\n",
       "      <td>东南风,东北风,西北风,西南风</td>\n",
       "      <td>中度污染,重度污染,良,优,轻度污染</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    月份  最高温度  最低温度                         风向列表                   空气质量列表\n",
       "0    1     7   -12     东北风,北风,西北风,西南风,南风,东南风,东风            良,优,轻度污染,中度污染\n",
       "1    2    12   -10      北风,西南风,南风,西北风,西风,东北风,东风       良,优,轻度污染,中度污染,重度污染\n",
       "2    3    27    -4         西南风,北风,东南风,南风,东北风,东风  优,良,重度污染,轻度污染,中度污染,严重污染\n",
       "3    4    30     1        南风,北风,东北风,西南风,西北风,东南风       重度污染,良,优,轻度污染,中度污染\n",
       "4    5    35    10  东北风,北风,西南风,南风,东南风,东风,西风,西北风            轻度污染,优,良,中度污染\n",
       "5    6    38    17         西南风,南风,北风,东风,东南风,东北风            良,轻度污染,优,中度污染\n",
       "6    7    37    22      东南风,西南风,南风,东北风,东风,西风,北风                 良,轻度污染,优\n",
       "7    8    36    20         东南风,南风,东风,东北风,北风,西南风                 良,轻度污染,优\n",
       "8    9    31    11                南风,北风,西南风,西北风                 优,良,轻度污染\n",
       "9   10    25     1         北风,西北风,南风,西风,东北风,西南风            优,良,轻度污染,中度污染\n",
       "10  11    18    -4        南风,北风,西南风,东南风,西北风,东北风       良,轻度污染,重度污染,优,中度污染\n",
       "11  12    10   -12              东南风,东北风,西北风,西南风       中度污染,重度污染,良,优,轻度污染"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
